package com.qax.task.timer.core;

import com.qax.task.logger.Logger;
import com.qax.task.logger.LoggerFactory;
import com.qax.task.timer.*;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

/**
 * @author lianglei
 * @since 1.0
 */
public class TimeWheelCompletableFuture {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public static Timer wheelTimer = new HashedWheelTimer(new NamedThreadFactory("future-timeout", true));

    public static Timeout schedule(
            TimerTask task,
            long delay,
            TimeUnit unit
    ) {

        return wheelTimer.newTimeout(task, delay, unit);
    }

    public static Timeout submit(
            TimerTask task
    ) {
        return wheelTimer.newTimeout(task, 0, TimeUnit.SECONDS);
    }

}
